beta=.3
nm=2
maxx=100
price=60
x1=seq(from=0, by=1, length=maxx)
x2=seq(from=0, by=1, length=maxx)
#zet<- function(ix,iy){
#	if(ix+iy==price) return(10100)
#	else return(0)
#}
y=array(0,dim=nm)
alpha=array(0,dim=nm)
u1=array(0,dim=c(maxx,maxx))
u2=array(0,dim=c(maxx,maxx))
u=array(0,dim=c(maxx,maxx))
z=array(0,dim=c(maxx,maxx))
for(i in 1:nm){
	y[i]=100
	alpha[i]=.2+.2*i
}

#prospect <- 

for(i in 1:maxx){
	for(j in 1:maxx){
		c1=y[1]-(1-beta)*x1[i]-(beta/(nm-1))*x2[j]
		c2=y[2]-(1-beta)*x2[j]-(beta/(nm-1))*x2[i]
		pg=x1[i]+x2[j]
		u1[i,j]=c1+alpha[1]*pg
		u2[i,j]=c2+alpha[2]*pg
		#u[i,j]=max(u1[i,j],u2[i,j])
		u[i,j]=u1[i,j]*u2[i,j]
		#u[i,j]=u1[i,j]+u2[i,j]
		#z[i,j]=zet(x1[i],x2[j])
	}
}

persp(x1,x2,u,theta = 30, phi = 30)
#image(x1,x2,u)
#contour(x1,x2,z)

